﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Collections.Generic;
using System.Xml.Serialization;

#endregion


namespace ScrumTable.Config.ConfigManagement
{
    /// <summary>
    /// Represents the configuration data object for the scrum table
    /// ScreenConfig settings.
    /// </summary>      
    [Serializable] 
    public class ScreenConfig 
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------
       
        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------
        

        /// <summary>
        /// Stores the screen setting, change this value only via gui
        /// </summary>
        [XmlArray("ScreenNames")]
        [XmlArrayItem(Type = typeof(string), ElementName = "ScreenName")]
        public List<string> ScreenNames { get; set; }

        /// <summary>
        /// Gets or sets the point marker for the review touch area in the custom scrum map.
        /// </summary>
        [XmlIgnore]
        public bool IsMultiConfig { get { return ScreenNames.Count > 1; } }


        /// <summary>
        /// Stores the screen setting, change this value only via gui
        /// </summary>
        [XmlElement]
        public string StartControl { get; set; }


        /// <summary>
        /// Stores speficiy information for the screen
        /// </summary>
        [XmlElement]
        public string Args { get; set; }

        /// <summary>
        /// Stores the screen setting
        /// </summary>
        [XmlIgnore]
        public Type StartControlAsType
        {
            get
            {
                return (StartControl==null)?null:Type.GetType(StartControl);
            }
        } 

        #endregion

        #region Constructors / Destructor

        /// <summary>
        /// 
        /// </summary>
        public ScreenConfig()
        {
            ScreenNames = new List<string>();
        }

        /// <summary>
        /// 
        /// </summary>
        public ScreenConfig(string screen, Type type)
        {
            ScreenNames = new List<string>();
            ScreenNames.Add(screen);
            SetControlAsString(type);

        }

        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        #endregion

        #region Methods
        /// <summary>
        /// Sets the control for this screen.
        /// </summary>
        /// <param name="type"></param>
        public void SetControlAsString(Type type)
        {
            if (type == null)
            {
                StartControl = null;
            }
            else
            {
                StartControl = type.AssemblyQualifiedName.Substring(0, type.AssemblyQualifiedName.IndexOf(", Version"));
            }
        }

        #endregion

        #region Events

        #endregion

    }
}
